package bishi.youkushengshi;

import java.util.*;

public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int nums = in.nextInt();
        for(int i = 0; i < nums;i++) {
            //操作次数
            int x = in.nextInt();
            int ret = 0;
            while(x != 0) {
                //统计1的个数
                String demo = Integer.toBinaryString(x);
                int count = 0;
                for(char o : demo.toCharArray()) {
                    if(o == '1') {
                        count++;
                    }
                }
                //奇数
                if(count % 2 == 1) {
                        x = x ^ 1;


                }else {
                        //偶数
                        int heightIndex = demo.length() - 1;
                        int result = 1 << heightIndex;
                        x = x ^ result;
                }
                ret++;
            }


            System.out.println(ret);

        }
    }
}
